package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.User;
import com.itheima.health.vo.RoleVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {

    @Select("select ROLE_ID " +
            "from t_user_role " +
            "where USER_ID =#{id}")
    int[] findPermissionIdsbyRoleId(int id);

    @Insert("insert into t_user_role values(#{gid},#{roleId})")
    void addRoleAndPermissionId(@Param("gid") Integer gid, @Param("roleId") Integer roleId);

    @Delete("delete from t_user_role where role_id=#{id}")
    void deletePermissionInfoByRoleId(Integer id);

    @Select("select * from t_role")
    List<RoleVO> findAll();
}
